package cn.lili.controller.order;

import cn.lili.cache.auth.annotation.Authentication;
import cn.lili.common.vo.PageVO;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.order.order.entity.dos.PrizeOrder;
import cn.lili.modules.order.order.service.PrizeGoodsService;
import cn.lili.modules.order.order.service.PrizeOrderService;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "App抽奖")
@RequestMapping("/order/prize/app")
@RequiredArgsConstructor
@CrossOrigin
public class PrizeLotteryAppController {

    private final PrizeGoodsService prizeGoodsService;
    private final PrizeOrderService prizeOrderService;

    /**
     * 抽奖商品
     */
    @GetMapping("/raffleGoods")
    public ResultMessage<Object> raffleGoods() {
        return prizeGoodsService.raffleGoods();
    }

    /**
     * 获取当前剩余多少f分
     * @return 获取当前剩余多少f分
     */
    @GetMapping("/currentBalance")
    public ResultMessage<Object> currentBalance() {
        return prizeGoodsService.currentBalance();
    }

    /**
     * 免密支付抽奖
     */
    @GetMapping("/prizeDraw")
    public ResultMessage<Object> prizeDraw(@RequestParam String freePayKey) {
        return prizeOrderService.prizeDraw(freePayKey);
    }

    /**
     * 密码支付抽奖
     */
    @GetMapping("/passwordPaymentDraw")
    public ResultMessage<Object> passwordPaymentDraw() {
        return prizeOrderService.passwordPaymentDraw();
    }

    /**
     * 抽奖回调
     * @return 抽奖回调
     */
    @RequestMapping("/callback")
    public ResultMessage<Object> callback(PrizeOrder prizeOrder) {
        return prizeOrderService.callback(prizeOrder);
    }

    /**
     * 抽奖中奖记录
     */
    @GetMapping("/raffleWinningRecord")
    public ResultMessage<Object> raffleWinningRecord(PageVO pageVO) {
        return prizeOrderService.raffleWinningRecord(pageVO);
    }

    /**
     * 领取奖品
     */
    @PostMapping("/claimThePrize")
    public ResultMessage<Object> claimThePrize(@RequestBody PrizeOrder prizeOrder) {
        return prizeOrderService.claimThePrize(prizeOrder);
    }

    /**
     * 查看物流信息
     * @param id 订单ID
     */
    @GetMapping("/viewLogisticsInformation")
    public ResultMessage<Object> viewLogisticsInformation(@RequestParam String id) {
        return prizeOrderService.viewLogisticsInformation(id);
    }

    /**
     * 获取最近一次 订单收货地址
     * @return 获取最近一次 订单收货地址
     */
    @GetMapping("/getHistoricalAddress")
    public ResultMessage<Object> getHistoricalAddress() {
        return prizeOrderService.getHistoricalAddress();
    }

}
